import { HttpException, HttpStatus, Injectable } from "@nestjs/common";
import { IPramas } from "./app.controller";

@Injectable()
export class TestService {
    getAllData() {
        return 'data:数据'
    }
    getDeatilData(params:IPramas):string {
        if(!params.id || !Number.isInteger(params.id)) {
            throw new HttpException('必须包含id参数，并且id为数字',HttpStatus.BAD_REQUEST)
        }
        return 'detail' + params.id + 'and' + params.subId
    }
    getAddData(body,query:IPramas) {
        return 'add Data' + JSON.stringify(body) + 'id = ' + query.id
    }
    getUpdateData(body,query:IPramas) {
        return 'update Data' + JSON.stringify(body) + 'id = ' + query.id
    }
    getDeleteData(body:IPramas):string {
        return 'delete' + body.id
    }
}